<script type="text/javascript">
	function doSearchRank(value) {
		
	}
	
	//表格查询  
	function reloadRank() {
		var params = rank_list.datagrid('options').queryParams; //先取�?datagrid 的查询参�? 
		printLog(params);
		rank_list.datagrid('reload'); //设置好查询参�?reload �?��就可以了  
		rank_list.datagrid('unselectAll');
		rank_list.datagrid('uncheckAll');
	}


	function addRank() {
		createFromWindow("新增信息", "rank.do?editRank", "rank.do?saveRank",
				function(data) {
					reloadRank();
				});
	}
	
	function deleteRank() {
		var rows = rank_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除�?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('rank.do?deleteRankItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadRank();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请�?择操作记�?");
	    }
	}

	function editRank() {
		var rows = rank_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请�?择一条操作记�?');
				return;
			}
			createFromWindow("编辑信息", "rank.do?editRank&rankId=" + rows[0].id,
					"rank.do?saveRank", function(data) {
						reloadRank();
					},true);
		} else {
			showMsg('请�?择操作记�?');
		}

	}
	
	
	//操作按钮触发
	function operationsLookRank(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = rank_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "rank.do?editRank&rankId=" + id,
					null, null,false);
		} else {
			showMsg('请�?择查看记�?');
		}
	}
	
	function operationsEditRank(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = rank_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("编辑信息", "rank.do?editRank&rankId=" + id,
					"rank.do?saveRank", function(data) {
						reloadRank();
					},true);
		} else {
			showMsg('请�?择编辑记�?');
		}
	}
	
	function operationsSendRank() {
		printLog('发�?');
	}
	
	function operationsDeleteRank(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除�?', function(r) {
				if (r) {
					$.post('rank.do?deleteRankItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadRank(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请�?择操作记�?");
		}
	}
</script>

<#assign operations = "[\{shiro:'game:rank:refresh',onClick:'operationsLookRank',src:'static/jmax/images/notes/note.png',title:'查看'},
	   					\{shiro:'game:rank:edit',onClick:'operationsEditRank',src:'static/jmax/images/notes/note_edit.png',title:'编辑'},
	   					\{shiro:'game:rank:send',onClick:'operationsSendRank',src:'static/jmax/images/notes/note_go.png',title:'发�?'},
	   					\{shiro:'game:rank:delete',onClick:'operationsDeleteRank',src:'static/jmax/images/notes/note_delete.png',title:'删除'}
	  				   ]"/>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		
		<@eu.datagrid id="rank_list" toolbar="#ranklist_search" idField="id"
			 url="rank.do?loadList" rownumbers="true"
			 item="com.xdtech.game.vo.RankItem"/>
		
		<div id="ranklist_search">
			<div id="rank_toolbar" style="height: auto">
				
				<@eu.linkbutton showName="新增" shiro="game:rank:add" iconCls="icon-add" onclick="addRank()"/>
				<@eu.linkbutton showName="删除" shiro="game:rank:delete" iconCls="icon-remove" onclick="deleteRank()"/>
				<@eu.linkbutton showName="编辑" shiro="game:rank:edit" iconCls="icon-edit" onclick="editRank()"/>
				<@eu.linkbutton showName="刷新" shiro="game:rank:refresh" iconCls="icon-reload" onclick="reloadRank()"/>
				
			</div>
		</div>
	</div>
</div>